<template>
  <div id="app">
    <!-- <img :src="imgurl1"> -->
    <!-- <HelloWorld msg="Welcome to Your Vue.js App"/> -->
    <!-- <MyCom></MyCom> -->
    <!-- <MyNews></MyNews> -->

    <!-- <MyLogin></MyLogin> -->
    <router-link to="/login">登录</router-link>&nbsp;
    <!-- 这里要注意单引号 -->
    <router-link :to="{ name: 'MyCom', query: { name: '你好', age: 22 } }"
      >Mycom</router-link
    >&nbsp;
    <router-link :to="{ name: 'home', params: { id: 5 } }">首页</router-link
    >&nbsp; <router-link to="/news">新闻</router-link>&nbsp;
    <button @click="gohome">点击我跳转Home页面并传参</button>
    <button @click="gomycom">点击我跳转MyCom页面并传参</button>
    <button @click="gohistory">点我返回历史记录-2</button>
    <button @click="gohistory1">点我前进历史记录2</button>
    <router-view></router-view>
  </div>
</template>

<script>
// import HelloWorld from './components/HelloWorld.vue'
// import img from './assets/logo.png'
// import MyCom from './components/MyCom.vue'
// import MyNews from './components/MyNews.vue'
// import MyLogin from './components/MyLogin.vue'

export default {
  name: "App",
  data() {
    return {
      // imgurl:img,
      // imgurl1:require("./assets/logo.png")
    };
  },
  components: {
    // MyCom,
    // MyNews
    // MyLogin
  },
  methods: {
    gohome() {
      if (this.$route.name != "home") {
        this.$router.push({ name: "home", params: { id: 20 } });
      } else {
        console.log(1);
      }
    },
    gomycom() {
      if (this.$route.name != "MyCom") {
        console.log(this.$route);
        console.log(this.$router);
        this.$router.push({
          name: "MyCom",
          query: { name: "zhangsan", age: 20, sex: "men", phone: "123456" },
        });
      } else {
        console.log(1);
      }
    },
    gohistory() {
      this.$router.go(-2);
    },
    gohistory1() {
      this.$router.go(2);
    },
  },
};
</script>

<style>
#app {
  /* font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px; */
}
.mystyle {
  color: palevioletred;
}
</style>
